package ModelLayer;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class UnitTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class UnitTest
{
    private ModelLayer.Person person1;
    private ModelLayer.Copy copy1;
    private ModelLayer.Copy copy2;
    private ModelLayer.Copy copy3;
    private ModelLayer.DVD dVD1;
    private ModelLayer.Loan loan1;

    /**
     * Default constructor for test class UnitTest
     */
    public UnitTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
        person1 = new ModelLayer.Person("aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd");
        copy1 = new ModelLayer.Copy(1, "aoadasdasd", 23);
        copy2 = new ModelLayer.Copy(2, "aoadasdasd", 45);
        copy3 = new ModelLayer.Copy(3, "aoadasdasd", 54);
        dVD1 = new ModelLayer.DVD("aoadasdasd", "aoadasdasd", "aoadasdasd");
        loan1 = new ModelLayer.Loan("aoadasdasd", "aoadasdasd", person1, copy2);
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }

    @Test
    public void testCreationOfPersonObject()
    {
        ModelLayer.Person person1 = new ModelLayer.Person("1", "1", "1", "1", "1", "1");
    }

    @Test
    public void testPersonObjectGetMethods()
    {
        ModelLayer.Person person2 = new ModelLayer.Person("1", "1", "1", "1", "1", "1");
        assertEquals("1", person2.getAddress());
        assertEquals("1", person2.getCity());
        assertEquals("1", person2.getID());
        assertEquals("1", person2.getName());
        assertEquals("1", person2.getPhone());
        assertEquals("1", person2.getPostalCode());
    }

    @Test
    public void testPersonObjectSetMethods()
    {
        ModelLayer.Person person1 = new ModelLayer.Person("1", "1", "1", "1", "1", "1");
        assertEquals(true, person1.setAddress("2", "2", "2"));
        assertEquals("2", person1.getAddress());
        assertEquals(true, person1.setName("2"));
        assertEquals(false, person1.setName(""));
        assertEquals(false, person1.setPhone(""));
        assertEquals(true, person1.setPhone("2"));
    }

    @Test
    public void testCreationOfCopyObject()
    {
        ModelLayer.Copy copy2 = new ModelLayer.Copy(1, "1", 100.0);
    }

    @Test
    public void testCopyObjectGetMethods()
    {
        ModelLayer.Copy copy1 = new ModelLayer.Copy(1, "1", 100.0);
        assertEquals("1", copy1.getPurchaseDate());
        assertEquals(100.0, copy1.getPurchasePrice(), 0.1);
        assertEquals(1, copy1.getSerialNr());
    }

    @Test
    public void testCopyObjectSetMethods()
    {
        ModelLayer.Copy copy1 = new ModelLayer.Copy(1, "1", 100.0);
        assertEquals(true, copy1.setPurchaseDate("2"));
        assertEquals(false, copy1.setPurchaseDate(""));
        assertEquals(true, copy1.setPurchasePrice(50.0));
        assertEquals(false, copy1.setPurchasePrice(0.0));
        assertEquals(true, copy1.setSerialNr(2));
        assertEquals(false, copy1.setSerialNr(0));
    }

    @Test
    public void testCreationOfDVDObject()
    {
        ModelLayer.DVD dVD1 = new ModelLayer.DVD("1", "1", "1");
    }

    @Test
    public void testDVDObjectGetMethods()
    {
        ModelLayer.DVD dVD1 = new ModelLayer.DVD("1", "1", "1");
        ModelLayer.Copy copy1 = new ModelLayer.Copy(1, "1", 34.0);
        ModelLayer.Copy copy2 = new ModelLayer.Copy(2, "1", 87.0);
        dVD1.addFiles(1, copy1);
        dVD1.addFiles(2, copy2);
        assertEquals("1", dVD1.getArtist());
        assertNotNull(dVD1.getCopies());
        assertNotNull(dVD1.getCopy(1));
        assertEquals("1", dVD1.getPubDate());
        assertEquals("1", dVD1.getTitle());
    }

    @Test
    public void testDVDObjectSetMethods()
    {
        ModelLayer.DVD dVD1 = new ModelLayer.DVD("1", "1", "1");
        assertEquals(true, dVD1.setArtist("2"));
        assertEquals(false, dVD1.setArtist(""));
        assertEquals("1", dVD1.getTitle());
        assertEquals(true, dVD1.setId(1));
        assertEquals(false, dVD1.setId(0));
        assertEquals(true, dVD1.setPubDate("2"));
        assertEquals(false, dVD1.setPubDate(""));
        assertEquals(true, dVD1.setTitle("2"));
        assertEquals(false, dVD1.setTitle(""));
    }

    @Test
    public void testCreationOfLoanObject()
    {
        ModelLayer.Copy copy1 = new ModelLayer.Copy(1, "aoadasdasd", 23);
        ModelLayer.Person person1 = new ModelLayer.Person("aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd");
        ModelLayer.Loan loan1 = new ModelLayer.Loan("aoadasdasd", "aoadasdasd", person1, copy1);
    }

    @Test
    public void testLoanObjectGetMethods()
    {
        ModelLayer.Copy copy1 = new ModelLayer.Copy(1, "aoadasdasd", 23);
        ModelLayer.Person person1 = new ModelLayer.Person("aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd", "aoadasdasd");
        ModelLayer.Loan loan1 = new ModelLayer.Loan("aoadasdasd", "aoadasdasd", person1, copy1);
        assertNotNull(loan1.getCopy());
        assertEquals("aoadasdasd", loan1.getFromDate());
        assertNotNull(loan1.getPerson());
        assertEquals(true, loan1.getState());
        assertEquals(null, loan1.getToDate());
    }
}











